Skip to content

feat(connectors): check every connector call against OPA rules - #36

Open
aktech wants to merge 13 commits into
mainfrom
feat/connectors-opa
Open

aktech wants to merge 13 commits into
mainfrom
feat/connectors-opa

Conversation

@aktech

@aktech aktech commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

The connector broker checks every call against Rego rules run by OPA embedded in the gateway, read from a mounted directory and reloaded on change. Deny answers the person with the rule's reason, require_approval makes the call a plan, and anything undecidable denies.

opa-connector

The thing that will let us do this:

opa-flow.mp4

Closes #3

Details
  • Input and decision shape from Design discussion: OPA policy integration for agent model and tool calls #14; each decision's rules and revision go in the audit row. Helm mounts rules inline or from an existing ConfigMap; docs in admin/connector-policy.
  • Deviations from Design discussion: OPA policy integration for agent model and tool calls #14: no agent.client in the input (the client chooses it); no agent template field yet (agent.name/app are owner-chosen, documented); findings always empty until detectors exist; the reload polls every 10s instead of watching files; rules are type-checked against the input schema and must use strict mode.
  • OPA v1.22.4: exact pin, OSV {} for it and all 64 added or bumped modules (none under 14 days old), open-policy-agent org with MAINTAINERS.md unchanged, tag commit matches the proxy, path matches the OPA docs, govulncheck@v1.9.0 ./... reaches no vulnerability. Details in DEPENDENCIES.md.
  • Not linked into javo local.

aktech added 13 commits December 1, 2026 12:18
The broker now asks Open Policy Agent, embedded in the gateway, before
it forwards a read, makes a write into a plan, or applies an approved
plan. Rules are the .rego files in connectors.policy.rulesDir, read
again every 10 seconds; a change that does not load keeps the last
rules that did.

- Rules return deny or require_approval sets of {title, description}
  from packages tapas.rules.<name> or tapas.admin.<name>. A deny
  answers the person with the descriptions; require_approval turns the
  call into a plan.
- The input document follows the design discussion: checkpoint, phase,
  who, agent, where, what, findings (empty until detectors exist), and
  approval when an approved plan is applied. The agent that proposed a
  plan is stored with it and given to the rules again at apply.
- Fails closed: no rules, rules that do not load (syntax, packages
  outside the namespace, deny not a partial set, no METADATA title and
  description, network or env built-ins), an evaluation error, a 2s
  timeout, or an answer of another shape all deny. A broker with no
  policy denies; the allow-all default is gone.
- Each decision's effect, rule titles and rule revision go into the
  call's audit row.
- connectors.enabled now needs connectors.policy.rulesDir.
- Example rules (Greenhouse for recruiting only, approval for email
  sends and Frames writes) with Rego tests run by go test.
- Adds github.com/open-policy-agent/opa v1.22.4; checks recorded in
  DEPENDENCIES.md.
What an MCP client calls itself is chosen by the client, and is empty
when a call is planned through the plans API, so a rule resting on it
could be fooled or miss. The startup log now says every connector call
is denied when no rules have loaded yet, instead of naming last rules
that never existed.
With config.connectors.enabled the gateway needs a directory of Rego
rules. connectorPolicy.configMap names an existing ConfigMap (such as
one synced from a GitOps repository); connectorPolicy.rules renders the
files into javo-connector-policy. The chart mounts the ConfigMap whole,
read-only, at /etc/javo-policy (no subPath, so the mount updates and the
gateway reloads the rules) and sets connectors.policy.rulesDir there
unless it is set. It refuses to render with connectors on and neither or
both set. With connectors off nothing is added.
A Connector policy page for admins: when calls are checked, the input document, the rule contract with worked examples, testing with opa test, loading through the chart's connectorPolicy values, what fails closed and what the audit log records. Connectors and the Helm values reference link to it and name connectors.policy.rulesDir.
- A deny or require_approval nested in another name (x.deny) loaded
  and was never read; it is now refused.
- Rules are type-checked against the input document, so a misspelt or
  removed input field is refused instead of never firing, and a rule
  set with no deny or require_approval rule at all does not load.
- json.match_schema and json.verify_schema fetch a schema's $ref by URL
  or file path; both are refused, and no built-in may reach a host.
- The rules are read from the directory a ConfigMap's ..data names, so
  an update never loads old and new files mixed.
- A failed policy check is logged with the connector, tool and rules'
  revision. Files that failed to load are logged once, not recompiled
  every 10 seconds.
…d's decision

- A connector call planned through POST /api/plans, not through /mcp,
  now writes its audit row with the policy's decision, allowed or
  denied; without the row no plan is made.
- A read the rules held for approval keeps that decision in its row,
  unless planning denied it.
- A plan with no record of the agent that proposed it (one made before
  that record was kept) is denied when applied.
- The chart mounts the rules at config.connectors.policy.rulesDir when
  it is set, so the gateway reads them where they are.
- The Frames example drops a deny that could never fire: Tapas applies
  a plan only for the person who approved it.
- The docs drop agent.client, add opa check --strict, say agent.name
  and agent.app are chosen by the app's owner, and list every case now
  refused at load.
…out of logs

- A rule in tapas.rules or tapas.admin whose name is computed (y[k])
  could be deny without being read where deny is; such names are now
  refused when the rules load.
- A failed evaluation is described by OPA's error code and the rule's
  file and line, not OPA's message, which can quote an argument's value
  into the gateway log.
- A load cut short by its context does not mark the files as broken.
- Test: a plan whose audit row cannot be written is not made.
The local build leaves Open Policy Agent out; nothing checked that cut,
so an import from a file both builds compile would have gone unnoticed.
- Rules are mounted at connectors.policy.rulesDir, which the chart sets
  to /etc/javo-policy unless it is set.
- Reads no longer run straight away: the policy can deny them or hold
  them for approval, and the person sees the policy's reason.
- Rules only take access away; Tapas's own access check runs first.
- Computed rule names are listed among what is refused at load.
- The architecture page names the policy check; DEPENDENCIES lists
  v1/topdown and the refused JSON schema built-ins.
…e load

The built-in cases had no deny rule, so they were refused for that and
passed even with every built-in allowed. Each now carries a valid rule
set, so only the built-in can refuse it.
The schema rules are type-checked against is written out by hand. A
test now compares its fields with those of a fully set policy.Input, so
a field added to one side only fails.
A job's token is refused before the policy is asked, so the field was
always false; a rule resting on it could never fire. A rule that reads
it is now refused when it loads.
@aktech
aktech marked this pull request as ready for review December 1, 2026 19:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check every connector call against Open Policy Agent in the broker

1 participant